package com.leyou.item.dto;

import com.leyou.common.dto.BaseDTO;
import com.leyou.common.entity.BaseEntity;
import com.leyou.item.entity.Spu;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
public class PageSpuDTO extends BaseDTO {
//    private Long brandId;
//    private String brandName;
//    private String categoryName;
//    private Long cid1;
//    private Long cid2;
//    private Long cid3;
//    private Long id;
//    private String name;
//    private Boolean saleable;

    private List<Spu> spuList;
    private Long total;
    private Long totalPage;

    public PageSpuDTO(BaseEntity entity) {
        super(entity);
    }

    public static <T extends BaseEntity> List<PageSpuDTO> convertEntityList(Collection<T> list) {
        if(list == null){
            return Collections.emptyList();
        }
        return list.stream().map(PageSpuDTO::new).collect(Collectors.toList());
    }

}
